package com.adrian.misc.fractal.math;

public class RectArea {
	private ComplexNumber Z1;
	private ComplexNumber Z2;

	public ComplexNumber cStart;
	public double width;
	public double height;

	public RectArea (ComplexNumber z1, ComplexNumber z2) {
		set (z1,z2);
	}

	public RectArea (RectArea ra) {
		set(new ComplexNumber(ra.cStart),ra.width,ra.height);
		System.out.println("REctaArea create c1:" + ra.Z1 + ", C2:" +ra.Z2);
	}

	public void set (ComplexNumber z1, ComplexNumber z2) {
		Z1 = z1;
		Z2 = z2;
		cStart = new ComplexNumber	(Z1.X < Z2.X ? Z1.X : Z2.X,
			 	Z1.Y > Z2.Y ? Z1.Y : Z2.Y);
		width 	= Math.abs(Z1.X - Z2.X);
		height 	= Math.abs(Z1.Y - Z2.Y);
		
	}

	public void set (ComplexNumber cNum, double width, double height) {
		Z1 = cNum;
		Z2 = new ComplexNumber(cNum.X + width, cNum.Y + height );		
		cStart = cNum;
		this.width = width;
		this.height = height;
	}
	
	public String toString() {
		return "RectArea:{" + cStart +":" + width +"," +height+ "}"; 
	}
}
